package com.hn658.base.message.common.enums;

import com.hn658.base.message.common.exceptions.FilterException;


/**
 * 群成员类型
 * @ClassName: MemberType 
 */
public enum MemberType {
    Master(1, "群主"),
    Manager(2, "管理员"),
    Member(3,"成员");
    private int code;

    private String name;

    MemberType(int code, String name){
        this.code = code;
        this.name = name;
    }

    /**
     * @return the code
     */
    public int getCode() {
        return code;
    }

    public String getName(){
        return name;
    }

    /**
     * 根据code值获取对应的枚举
     * @param code
     * @return
     */
    public static MemberType getTypeByCode(int code){
        for(MemberType type : MemberType.values()){
            if(type.getCode() == code){
                return type;
            }
        }

        throw new FilterException(FilterException.WrongDeviceType);
    }
}
